﻿namespace UnityEditor
{
    using System;
    using System.Runtime.CompilerServices;
    using UnityEngine;

    public sealed class VCTask
    {
        private DoneDelegate doneDelegate;
        private IntPtr m_thisDummy;
        private object m_user;

        public event DoneDelegate OnDone;

        private void Call_OnDone()
        {
            if (this.OnDone != null)
            {
                this.OnDone(this);
            }
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void Dispose();
        ~VCTask()
        {
            this.Dispose();
        }

        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern VCAsset[] Internal_GetAssetList();
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern VCChangelist[] Internal_GetChangelists();
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        private extern VCMessage[] Internal_GetMessages();
        [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall]
        public extern void Wait();

        public VCAssetList assetList
        {
            get
            {
                VCAssetList list = new VCAssetList();
                foreach (VCAsset asset in this.Internal_GetAssetList())
                {
                    list.Add(asset);
                }
                return list;
            }
        }

        public VCChanges changesList
        {
            get
            {
                VCChanges changes = new VCChanges();
                foreach (VCChangelist changelist in this.Internal_GetChangelists())
                {
                    changes.Add(changelist);
                }
                return changes;
            }
        }

        public VCMessage[] messages { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string name { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public int resultCode { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public bool success { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public string text { [MethodImpl(MethodImplOptions.InternalCall), WrapperlessIcall] get; }

        public object user
        {
            get
            {
                return this.m_user;
            }
            set
            {
                this.m_user = value;
            }
        }

        public delegate void DoneDelegate(VCTask task);
    }
}

